package render;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;

import gameobj.Player;
import manager.LevelManager;

/**
 * @author Passerby
 * @说明
 * 游戏中的UI显示
 */
public class MainUI {
//	由于要获取player的血量，故player也作为成员变量
	Player player = null;
	Font healthFont = null;
	LevelManager lm = null;
	
	public MainUI(Player player) {
		this.player = player;
		healthFont = new Font("微软雅黑", Font.BOLD, 24);
		lm = LevelManager.get();
	}
	
	public void draw(Graphics g) {
		Graphics2D g2d = (Graphics2D) g;
//		血量框
		g2d.setStroke(new BasicStroke(2.0f));
		g2d.setColor(Color.red);
		g2d.drawRect(350, 50, 100, 20);
//		血量
		int width = player.getHealth() * 100 / player.getMaxHealth();
		g2d.fillRect(350, 50, width, 20);
//		血量数值
		g2d.setFont(healthFont);
		g2d.drawString("" + player.getHealth(), 480, 70);
		
		g2d.drawString("Score", 80, 70);
		
		g2d.drawString("" + lm.getScore(), 200, 70);
	}
}
